using System;
using System.Data;
using System.Data.SqlClient;

using EntLibEC.Cmn;
using EntLibEC.Info.Basic;

namespace EntLibEC.Dac.Basic
{
	/// <summary>
	/// Summary description for UserRolePrivilegeDac.
	/// </summary>
	public class UserRolePrivilegeDac
	{
		public UserRolePrivilegeDac()
		{
			//
			// TODO: Add constructor logic here
			//
		}

		

		public int RolePrivilegeInsert(int roleSysNo, int privilegeSysNo)
		{
			string sql = @"INSERT INTO Ent_Sys_Role_Privilege
                            (
                            RoleSysNo, PrivilegeSysNo
                            )
                            VALUES (
                            @RoleSysNo, @PrivilegeSysNo
                            )";
			SqlCommand cmd = new SqlCommand(sql);

			SqlParameter paramRoleSysNo = new SqlParameter("@RoleSysNo", SqlDbType.Int,4);
			SqlParameter paramPrivilegeSysNo = new SqlParameter("@PrivilegeSysNo", SqlDbType.Int,4);

			paramRoleSysNo.Value = roleSysNo;
			paramPrivilegeSysNo.Value = privilegeSysNo;

			cmd.Parameters.Add(paramRoleSysNo);
			cmd.Parameters.Add(paramPrivilegeSysNo);

			return SqlHelper.ExecuteNonQuery(cmd);
		}
		public int RolePrivilegeDelete(int rolePirvilegeSysNo)
		{
			string sql = "delete from Ent_Sys_Role_Privilege where sysno =" + rolePirvilegeSysNo;

			SqlCommand cmd = new SqlCommand(sql);
			return SqlHelper.ExecuteNonQuery(cmd);
		}
		public int UserRoleInsert(int userSysNo, int roleSysNo)
		{
			string sql = "insert into Ent_Sys_User_Role(usersysno, rolesysno) values( " + userSysNo + "," + roleSysNo + ")";
			SqlCommand cmd = new SqlCommand(sql);
			return SqlHelper.ExecuteNonQuery(cmd);
		}
		public int UserRoleDelete(int userRoleSysNo)
		{
			string sql = "delete from Ent_Sys_User_Role where sysno =" + userRoleSysNo;
			SqlCommand cmd = new SqlCommand(sql);
			return SqlHelper.ExecuteNonQuery(cmd);
		}
	}
}
